<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{{site_config.store_title}} | 后台登陆</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <link href="/public/tool/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/public/admin/css/AdminLTE.min.css" rel="stylesheet" type="text/css"/>
    <link href="/public/tool/iCheck/square/blue.css" rel="stylesheet" type="text/css"/>
    <style>#imgVerify {
        width: 120px;
        margin: 0 auto;
        text-align: center;
        display: block;
    }    </style>
    <script>
        function detectBrowser() {
            var browser = navigator.appName
            if (navigator.userAgent.indexOf("MSIE") > 0) {
                var b_version = navigator.appVersion
                var version = b_version.split(";");
                var trim_Version = version[1].replace(/[ ]/g, "");
                if ((browser == "Netscape" || browser == "Microsoft Internet Explorer")) {
                    if (trim_Version == 'MSIE8.0' || trim_Version == 'MSIE7.0' || trim_Version == 'MSIE6.0') {
                        alert('请使用IE9.0版本以上进行访问');
                        return;
                    }
                }
            }
        }

        detectBrowser();
    </script>
</head>

<body class="login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="JavaScript:;"><b>{{site_config.store_title}}</b></a>
    </div>
    <div class="login-box-body">
        <p class="login-box-msg">管理后台</p>
        <form method="post" id="submitForm">
            <div class="form-group has-feedback">
                <input type="text" name="username" id="username" class="form-control" placeholder="账号"/>
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" name="password" class="form-control" id="password" placeholder="密码"/>
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <opinioncontrol realtime="true" opinion_name="vertify_code" default="true">
                    <div class="row" style="padding-right: 65px;">
                        <div class="col-xs-8">
                            <input style="width: 135px" type="text" name="vertify" class="form-control"
                                   placeholder="验证码"/>
                        </div>
                        <div class="col-xs-4">
                            <img id="imgVerify" style="cursor:pointer;" src="{{helper.pathFor('adcocap')}}" onclick="fleshVerify()"/>
                        </div>
                    </div>
                </opinioncontrol>
            </div>
            <!--
            <div class="row">
              <div class="col-xs-8">
                <div class="checkbox icheck">
                  <label><input type="checkbox"> 记住密码  </label>
                </div>
              </div>
              <div class="col-xs-4">
                <div class="checkbox icheck">
                  <label><a href="#">找回密码</a></label>
                </div>
              </div>
            </div>-->
            <div class="form-group">
                <button type="button" class="btn btn-primary btn-block btn-flat" id="submit">立即登陆</button>
            </div>
        </form>
    </div>

    <div class="margin text-center">
        <div class="copyright">
            2017-2020 &copy; <a href="javascript:;">{{site_config.store_name}}</a>出品
            <br/>
        </div>
    </div>
</div>
<script src="/public/tool/jQuery/jQuery-2.1.4.min.js" type="text/javascript"></script>
<script src="/public/tool/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/public/tool/iCheck/icheck.min.js" type="text/javascript"></script>
<script src="/public/js/layer/layer.js" type="text/javascript"></script><!-- 弹窗js 参考文档 http://layer.layui.com/-->
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });
    });

    window.onload = function () {
        document.onkeydown = function () {
            if (event.keyCode == 13) {
                checkLogin();
            }
        }
    }

    function fleshVerify() {
        //重载验证码
        let v = Math.random();
        $('#imgVerify').attr('src', "{{helper.pathFor('adcocap')}}?rnad=" + v);
    }


    jQuery.fn.center = function () {
        this.css("position", "absolute");
        this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +
            $(window).scrollTop()) - 30 + "px");
        this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
            $(window).scrollLeft()) + "px");
        return this;
    }

    $("#submit").click(function(){
        var data = $("#submitForm").serializeArray();
        postData = {};
        $(data).each(function(i){
            postData[this.name] = this.value;
        });
        let url = "{{helper.pathFor('adinlo')}}";
        $.ajax({
            type: 'POST',
            url: url,
            data: postData,
            dataType: 'JSON',
            success: function(result) {
                if(result.status == 1) {
                    setTimeout(()=>location.href="{{helper.pathFor('adinin')}}",2000);
                    return layer.msg(result.message);
                }else if(result.status == 0) {
                    return layer.msg(result.message);;
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert('网络失败，请刷新页面后重试', {icon: 2});
            }
        });
    });
    $(function () {
        if(window  !=window.top){
            window.top.location.replace(window.location)
        }
    });
</script>
</body>
</html>